<template>
  <div class="app">
      <header>
          <router-link to="/home/move"><span>back</span></router-link>
          <h3>美团电影</h3>
      </header>
      <nav>
          <div class="left">
              <p>美团账号登录</p>
          </div>
          <div class="right">
              <p>手机验证登录</p>
          </div>
      </nav>
      <section>
          <p><input type="text" placeholder="账号、手机号、email号" v-model="parms.user"></p>
          <p><input type="text" placeholder="请输入你的密码" v-model="parms.pwd"></p>
          <p><button @click="login">登录</button></p>
          <div class="hds">
              <p>立即注册</p>
              <p>找回密码</p>
          </div>
      </section>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data () {
    return {
      parms: {
        user: '',
        pwd: ''
      }
    }
  },
  methods: {
    login () {
      axios.post('/login', this.parms).then(res => {
        alert(res.data.msg)
        localStorage.setItem('token', res.data.token)
        // console.log(this.$route)
        // 找到从哪里进入到的登录界面
        const fullPath = this.$route.query.fullPath || '/home'
        // 将页面替换
        this.$router.replace(fullPath)
      })
    }
  }
}
</script>

<style lang="less" scoped>
header{
    width: 100%;
    height: 50px;
    background: #e54847;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    span{
        position: absolute;
        left: 10px;
        top: 15px;
    }
}
nav{
    display: flex;
    align-items: center;
    width: 100%;
    border-bottom: 1px solid #ccc;
    .left{
        width: 50%;
        height: 40px;
        line-height: 40px;
        text-align: center;
        border-bottom: 3px solid rgb(224, 123, 6);
    }
    .right{
        width: 50%;
        height: 40px;
        line-height: 40px;
        text-align: center;
    }
}
section {
    p{
        width: 100%;
        height: 60px;
        padding: 10px;
        input{
            width: 100%;
            height: 100%;
            padding-left: 10px;
            border: none;
            border-bottom: 1px solid #ccc;
            outline: 0;
            color: #df2d2d;
            &:focus{
                background: #ccc;
                border-radius: 3px;
            }
        }
        button{
            width: 100%;
            height: 90%;
            background: #df2d2d;
            color: #fff;
            border: 0;
            outline: 0;
        }
    }
}
.hds{
    display: flex;
    color: #FE8C00;
    p{
        font-size: 14px;
          &:nth-child(2){
            text-align: right;
        }
    }
}
</style>
